package com.apanal.qlife.common.factory;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.ContextLoader;

/**
 * Srping上下文获取，注意此类只能运行于Web环境
 * 
 * @author shuliangxing
 * 
 * @date 2015-3-16下午2:21:20
 */
public class SpringContextHolder {
	public static ApplicationContext getApplicationContext() {
		return ContextLoader.getCurrentWebApplicationContext();
	}

	@SuppressWarnings("unchecked")
	public static <T> T getBean(String name) {
		return (T) getApplicationContext().getBean(name);
	}
}
